
// ChemGraphicsDoc.h : interface of the CChemGraphicsDoc class
//


#pragma once

#include "BaseShape.h"
#include "CSymbol.h"

class CChemGraphicsDoc : public CDocument
{
protected: // create from serialization only
	CChemGraphicsDoc();
	DECLARE_DYNCREATE(CChemGraphicsDoc)

// Attributes
protected:
	int m_nCaretVerSize;
	CDWordArray m_arCaret;
	int m_nCaretIndex; 
	CFont m_ftDraw;
public:
	CString m_szText; 
	
public:
	//Lop m_arrShape luu tru thong tin cac hinh duoc ve
	CArray<BaseShape*, BaseShape*> m_arrShape;
	int m_CurrText;
	//28/09/2014 - Tracker xung quanh hinh
	CRectTracker m_tracker;
	BOOL m_bAllowInvert;
	//Luu button duoc chon
	BASESHAPE__T m_nShapeType;
	COLORREF m_clrBack;		//thuoc tinh mau cho hinh ve
	COLORREF m_cPenColor;	//thuoc tinh mau cho net ve
// Operations
public:
	//Tra ve vi tri hinh duoc chon trong mang m_arrShape - rect
	INT isPointShape(CPoint);
	//Tra ve vi tri hinh duoc chon trong mang m_arrShape - bond
	void LineEquation2(INT&, INT&, INT&, int);
	INT isPointShape2(CPoint);
	//hien thi null rect 
	INT isPointShape3(CPoint);
	void LineEquation3(INT&, INT&, INT&, INT, int);
	//void getCenter(CPoint &, INT, int);
	BOOL Between(INT, CPoint, int);
	void LineDist(float &, float &, float &, INT, CPoint, int);
	float Distance(CPoint, CPoint);
	void DeleteTracker();
// Overrides
public:
	void ForwardCaret(); 
	void BackwardCaret();
	POINT GetCaretPosition();
	int GetCaretVerSize(){return m_nCaretVerSize;}
	void GetCGDIView();
	void AddChar(UINT, UINT); 
	void DeleteChar(BOOL); 
	void HomeCaret();
	void EndCaret();
	void ForwardCaretToBlank();
	void BackwardCaretToBlank();
	void SetCaret(CPoint);
public:
	virtual BOOL OnNewDocument();
	virtual void Serialize(CArchive& ar);
#ifdef SHARED_HANDLERS
	virtual void InitializeSearchContent();
	virtual void OnDrawThumbnail(CDC& dc, LPRECT lprcBounds);
#endif // SHARED_HANDLERS

// Implementation
public:
	virtual ~CChemGraphicsDoc();
#ifdef _DEBUG
	virtual void AssertValid() const;
	virtual void Dump(CDumpContext& dc) const;
#endif

protected:

// Generated message map functions
protected:
	//28/09/2014 tracker
	//{{AFX_MSG(CTrackerDoc)
	afx_msg void OnEditDottedline();
	afx_msg void OnUpdateEditDottedline(CCmdUI* pCmdUI);
	afx_msg void OnEditHatchedborder();
	afx_msg void OnUpdateEditHatchedborder(CCmdUI* pCmdUI);
	afx_msg void OnUpdateEditHatchedinside(CCmdUI* pCmdUI);
	afx_msg void OnEditHatchedinside();
	afx_msg void OnEditResizeinside();
	afx_msg void OnUpdateEditResizeinside(CCmdUI* pCmdUI);
	afx_msg void OnEditResizeoutside();
	afx_msg void OnUpdateEditResizeoutside(CCmdUI* pCmdUI);
	afx_msg void OnEditSolidline();
	afx_msg void OnUpdateEditSolidline(CCmdUI* pCmdUI);
	afx_msg void OnEditAllowInvert();
	afx_msg void OnUpdateEditAllowInvert(CCmdUI* pCmdUI);
	afx_msg void OnToolsOptions();
	//}}AFX_MSG
	//{{SHAPE_MSG
	afx_msg void OnDrawArrow();
	afx_msg void OnDrawLine();
	afx_msg void OnDrawSquare();
	afx_msg void OnDrawRectangle();
	afx_msg void OnDrawCircle();
	afx_msg void OnDrawEclipse();
	afx_msg void OnDrawCurver();
	//}}SHAPE_MSG
	//{{BOND_MSG
	afx_msg void OnDrawOneBond();
	afx_msg void OnDrawDoubleBond();
	afx_msg void OnDrawThreeBond();
	afx_msg void OnDrawCycloHexane();
	afx_msg void OnDrawCircleHexane();	
	afx_msg void OnDrawBenzene();
	afx_msg void OnDrawCirclePentane();
	afx_msg void OnDrawWedgeBond();
	afx_msg void OnDrawHashedWedge();
	afx_msg void OnDrawHashBond();
	afx_msg void OnDrawWhiteHashBond();
	afx_msg void OnDrawUndefineBond();
	afx_msg void OnDrawBoldBond();
	afx_msg void OnDrawDoubleBoldBond();
	afx_msg void OnDrawDoubleArrow();
	//}}BOND_MSG
	//{{OBITAN_MSG
	afx_msg void OnDrawCircleObitan();
	afx_msg void OnDrawBCircleObitan();
	afx_msg void OnDrawEclipseObitan();
	afx_msg void OnDrawBEclipseObitan();
	afx_msg void OnDrawFunnelObitan();
	afx_msg void OnDrawBFunnelObitan();
	afx_msg void OnDrawDFunnelObitan();
	afx_msg void OnDrawDBFunnelObitan();
	afx_msg void OnDrawDFunnelObitan1();
	afx_msg void OnDrawDBFunnelObitan1();
	afx_msg void OnDrawDBFunnelObitan2();
	//}}OBITAN_MSG
	//{{SYMBOL_MSG
	afx_msg void OnDrawPlusCircle();
	afx_msg void OnDrawSubCircle();
	afx_msg void OnDrawPlus();
	afx_msg void OnDrawSub();
	afx_msg void OnDrawPlusPoint();
	afx_msg void OnDrawSubPoint();
	afx_msg void OnDrawOnePoint();
	afx_msg void OnDrawDoublePoint();
	//}}SYMBOL_MSG

	DECLARE_MESSAGE_MAP()

#ifdef SHARED_HANDLERS
	// Helper function that sets search content for a Search Handler
	void SetSearchContent(const CString& value);
#endif // SHARED_HANDLERS
public:
	afx_msg void OnDialogFont();
	afx_msg void OnUpdateDialogFont(CCmdUI *pCmdUI);
	afx_msg void OnEditPaste();
	afx_msg void OnUpdateEditPaste(CCmdUI *pCmdUI);
	afx_msg void OnText();
};
